#include "push_phpredis.h"

extern void push_db_data(string addr, string query, string error, long execute_micro_time);

void push_phpredis_handler(zend_execute_data *execute_data, long execute_micro_time, string class_name, string function_name)
{
    if (function_name == "__construct" || function_name == "__destruct")
    {
        return;
    }

    zval *obj = execute_data->object;
    redis_object *redis = (redis_object *)zend_object_store_get_object(obj TSRMLS_CC);
    int port = redis->sock->port;
    string ip = redis->sock->host->val;
    string addr = ip + ":" + to_string(port);
    string query = class_name + "->" + function_name;
    string err = "";

    push_db_data(addr, query, err, execute_micro_time);
}